home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Commodore Free 28
/
Commodore_Free_Issue_28_2009_Commodore_Computer_Club.d64
/
aa notes
< prev
next >
Wrap
Text File
|
2023-02-26
|
12KB
|
452 lines
u
****************
* READERS CODE *
****************
One of Commodore Free readers sent
this application in it's for the
commodore 16/plus 4 range of
computers called AA timer, if you
like these type in programs then let
me know as the reader has some more.
AA Timer notes
lines:-
10 - 110 REMarks about the program.
Clear & Initialise Screen. Set max.
Volume, people can then adjust their
sets accordingly. Print instructions
to test everything is working
properly, Wait for user input.
120 - 170 Discern user response and
act accordingly. Self explanatory
really, from above PRINT statements.
180 - 260 Pressing any key in the
menu above sends the user to this
menu. As there is a sound test
anyway, it isn't really necessary. It
was a precursor to figuring out
timings as I had to discover again
from memory, due to the intro. to
basic manual being long gone. I
still seek this, and the sequel/s...I
left it in as it is in line with the
spirit of the program. May be useful
for further study.
SERIOUS NOTE: Here I must make
another point that it is dangerous to
watch time. Not just because fellow
workers consider it "skiving off
work" but due to its effects on the
mind. People have become seriously
ill due to watching time. ...so I
took up programming!
DEBUGGING: With the above in mind
here is a tip to stop the computer
showing the count.
LIST310 put the cursor over the 0.
And type "1" and press RETURN repeat
with "2", 3, 4, 5,6,7
LIST310-318 (I always add one in the
list for good measure)
310 All you want is the first
command. So delete "Inst/Del" or
space out all the rest after. and
press RETURN.
311 You already have the first
command in the previous line, so
delete it here. -And in all the
following lines!) The first command
now should read x$=ti$. scrub out the
ones after it. Again you don't need
the command after this line so delete
all the others. The command gives
the computer something to calculate
with and updates according to the
current time which got reset to
midnight "000000" on the appropriate
key press to start the test.
312 Here is nowhere we need to
deviate from the pattern. Space/scrub
out the whole line. And from the
usual place type the following
command and press RETURN.
IFX$=>3 ANDX$<7 THEN314
313 we only need the print statement
here so delete the rest. By now
there should on be the NEXT
statement. And..
314 we only need the NextJ. You know
what to do!
Testing the debugging: Here we have
3 extra lines. The computer must
ignore these for the program to work.
And as we're only testing our
efforts thus far, we may need them
later. Hold shift down on the P of
the PRINT statement. And press the
key for inst.del. 4 times. Let go of
these. Type REM and press return
key. On all the lines.
Run program.
The first thing I found was that I
forgot to put inverted commas around
the "3" and the "7". And I think if
I live to be programming at 120 years
old, I'll still be forgetting this!
The second thing I found was that the
computer takes no notice unless it is
written exactly to original form.
That is "000003" ... "000007" because
it's a string not just a number!
Finally it now takes 12 seconds
because of the extra command. It
would be easier to change the printed
statement from 10 to 12 than to mess
about for next loop. Or would it?
Try changing this to a DO Loop! In
the first part of debugging we have
found The proof of the pudding is in
the eating, but in this case the
eating proved the programmer to be
the pudding! But no matter as this
teaches us that you can't always get
it right first time. So lets
continue.
Q. Will it work using ti$ instead of
x$ ?
The answer is yes, only we're up to
15 seconds on the count.
Now. LIST310-319 again change the
following lines accordingly.
310 DO
317 LOOPUNTILX$=>10
Now we need to take out the NEXT
STATEMENT IN 314. We will need to
repeat line 313 with what I have in
mind so go over to 313 and 314.
Now relist the required lines 310-319
312 ifx$=>"000003 and x$<"000007"
then ja%=1;elseja%=0
Use the shift and inst. del keys to
put the following in front of the
existing lines 313 & 314
313 ifja%=0then...
314 if ja% =1 then ... (now delete
everything after ";", in its place
type "counting" and press return to
store it.
I don't ever have any luck with do
loops. I'm fully expecting the
program to ignore my request to stop
at 10, and proceed to infinity!
There is a way out, firstly with run
stop. So it is safe to see if this
will happen. So run the program.
Again the mismatch error in 317,
corrected accordingly. It works,
albeit requiring a slight
modification.
ADD to the end of 313, the semicolon
";" symbol, followed by inverted
commas. And 9 spaces, followed by 9
arrow presses to the left. This takes
away the horrible " ing" on the
screen at the end etc. Now the
programmer is not so much the
pudding! ie. Run the program to test
it. It works! exit program and Save
it. Small note:
line240 refers to the original
for/next loop, not the new do/loop.
<OPTIONAL>
LIST310-325 at the ready prompt type
315 & press return, same for 316. As
these lines aren't needed. Had the
UNTIL command been missed, as I have
been known to get into a mess with
these. I would've put in: 315
ifx$=>"000010"then320 The > symbol
prevents any slight variation, more
likely if using ti$ from causing an
endless count.
<REMEMBER>
WARNING: DO NOT PLAY WITH NOR WATCH
TIME! It is only safe to glance on
such rare occasions' as are needed.
360 - 550 when the user escapes the
previous menu and gets to here.
There are 3 options.
In the lines 500 to 530 these are
reserved in case I ever want to add
to the program.
Lets look at the options. Print
statements 420&430 go along with this
but serve the dual use of putting a
space between functions and exit key.
This could easily be achieved in 440
with the down arrow.
390 & 470 The instruction to go to
egg timer at line 1210 on pressing
the corresponding key. The code also
gives away the order in which the
program was written. The original
idea was to provide a system to count
for any-one undertaking exercises
like Pilates or Yoga or whatever
Mute Point:
Much has been said in recent times
about the annoyance of "Spaghetti
coding", in this case the ability to
go with how I felt was liberating.
Giving a sense that I am doing this
for fun, not out of some laborious
obligation. And so what if no-one
else can read it, they'll have to
come to me!
Now though I'm in two minds. Do I
follow the paper page for page or
jump two pages to 1210 the way the
choice is listed? ...It makes more
sense to keep to the same page for
this purpose.
550 tells the computer if you have
any other key press than the options
given. Ignore it and go back to wait
for another one.
560 Interval beeps (key press 3)
570 - 640 Setting up sub menu, self
explanatory.
650 Sets time to midnight, the only
logical start point. oddly enough
there is a DO without a LOOP. Can
You see why 1. The computer never
notices, I haven't once received a DO
WITHOUT LOOP message! And 2. What
would need changing to incorporate
this as a full LOOP? (And don't say
"get a better programmer" or I'll
cry!)
660 look for a key press, but don't
wait for one! The difference being
the omission of the IFA$="" (NOTHING,
No Key Press) Then Jump back to this
line. The omission is quite correct
for this purpose.
670 if random isn't chosen. or
switched off there are specifics for
the sound command at the end of the
count. And so the computer must skip
the following three lines that give
random parameters. (experiment with
this all you want). Of course if
random is on then the reverse is
true.
705 In testing I seemed to get all
kinds of numbers -testable by adding
a print statement at production of
sound. ?"a";a ...etc.
710 makes sure Random is on or off,
and so only the parameters 0 and 1
are used.
720 mute function, if phone rings to
save stopping program. This will
order the program to jump to 880
where VOLume on/off is decided,
followed by the appropriate print.
then returned at 900 to -
730 - 910 checks relevant parts to
see if they need altering, carries
them out and returns for more. The
engine room so to speak. Can you
find where the duration is set?, bear
in mind that this would be at 0
therefore produce a constant and
annoying beep, if not set ahead of
the beep. 800&810 make it possible
for the alarm to go off at the
correct moment.
<DEBUGGING>
840 Why not goto650 and omit the
extra TI$ statement FROM 840?Too many
RETURNs, change the preceding returns
of the sub-menu to go to the last
RETURN of the type. In this case
change870 to goto910 This way it will
be easier to see where the menu of
type ends. More useful in larger
programs. Reduces "Spaghetti".
850 Appears to be a line left for
debugging in building. As nothing I
can see refers to it, and everything
skips it. It can be deleted to avoid
later confusion.
DO's and Dont's!
If you wished to LOOP as mentioned
earlier. Instead of Goto660, which
if you've followed the above is now
only820 as this does not reset time.
In this case it may be better just to
delete the DO as this menu isn't
really designed for it.
Finally, don't confuse keypress "X"
with variable x.
1000 The STOP WATCH menu.
A simple Start - Stop sub-menu. It's
easy to press "S" to show time even
with the line added to show when the
counter is started. The rest seems
self explanatory.
NOSTALGIA: I remember the "An
Introduction to BASIC part 1" has a
program with a timer that uses TI to
test and measure reflexes (Do not
confuse with the clock variable TI$),
I've been longing to find a copy of
this book and the sequel which I
would've loved to own. Not least
because it would enhance this and
future programs in this field.
In trying to recreate this from dead
reckoning and "memory" (hilarious
after 20 odd years!), I came up with
the following which can stand alone
or be added to the existing program.
If you do add it. Also change lines
420 print" 4 - Reflex Timer"
and
500 IFa$="4"then1540
and
1720 GOTO370
1550 REM *REFLEX TIMER*
1560 VOL8
1570 PRINT"clrhome REFLEX TIMER
"
1580 PRINT"down WAIT FOR BEEP"
1590 X=INT(RND(100)*750):REM PRINTX
1600 FOR J=0TOX:GETA$
1610 IFA$<>""THENPRINT"NO! WAIT FOR
BEEP
!":A$="":GOTO1590
1620 NEXT J
1630 SOUND1,300,10
1640 TI$="000000":REM PRINTTI
1650 GETA$
1660 REM PRINTTI
1670 IFA$=""THEN1650
1680 PRINTTI
1690 PRINT"ANOTHER GO Y/N?"
1700 GETA$:IFA$=""THEN1700
1710 IFA$<>"N"THEN1550
1720 END
A challenge would be to make it two
player using specific keys, and
saying who wins.
Also try adding a hall of fame. I
managed a fluke of 6 once. Averaging
about 19 or 20. occasionally being
as slow as 27.
1590 randomises the wait for a beep.
After REM is for debugging only.
1600 set length of wait according to
above.
1610 check that nothing is pressed
before beep. If it is say so, and
reset and importantly change time to
wait. This way person doesn't get
used to delay.
1620-30 obvious
1640 This resets TImer! Remembered
late in build.
1650-1680 Waits for key response and
measures delay using TI. It's not
seconds, and as I don't have the book
I don't know the rules of the timer.
A bit of fun nonetheless.
1690 - 1720 self explanatory.
1210 Egg Timer
Similar to stop watch, except set in
advance how well you want your egg
cooked. I can manage a full 9
minutes!
When time is up the program will beep
until the user shows it due care and
attentions by turning it off again.
==================================